using System;
using System.Collections.Generic;
using System.Text;

namespace AAM
{
    public class DatabaseTable : Attribute
    {

        public static DatabaseTable GetDatabaseTable(Type type)
        {
            object[] attributes = type.GetCustomAttributes(typeof(DatabaseTable), false);
            if (attributes == null || attributes.Length == 0) return null;
            DatabaseTable table = (DatabaseTable)attributes[0];
            if (table.TableAlias == null) table.TableAlias = type.Name;
            if (table.TableName == null) table.TableName = type.Name;
            return table;
        }

        private string tableName;
        private string tableAlias;

        public DatabaseTable()
        {
            TableAlias = null;
            TableName = null;
        }
        public string TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }
        public string TableAlias
        {
            get { return tableAlias; }
            set { tableAlias = value; }
        }

    }
}
